import 'package:flutter/material.dart';
import 'tabs/base.dart';
import 'tabs/category.dart';
import 'tabs/home.dart';
import 'tabs/animation.dart';
import './search.dart';
import 'tabs/user.dart';

class BottomNavigationBarPage extends StatefulWidget {
   int? arguments;
   BottomNavigationBarPage({super.key, required this.arguments});

  @override
  State<BottomNavigationBarPage> createState() => _BottomNavigationBarPageState();
}

class _BottomNavigationBarPageState extends State<BottomNavigationBarPage> {
  int _currentIndex = 0;
  final List<Widget> _pages = [
    HomePage(),
    BasePage(),
    CategoryPage(),
    AnimationPage(),
    UserPage(),
  ];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: IconButton(
          icon: Icon(Icons.menu),
          onPressed: () {
            print("左侧按钮图标");
          },
        ),
        title: const Text("Home Page"),
        actions: [
          IconButton(
            icon: Icon(Icons.search),
            onPressed: () {
              // 跳转到搜索页面
              Navigator.of(
                context,
              ).push(MaterialPageRoute(builder: (context) => SearchPage()));
              print("右侧按钮图标");
            },
          ),
          IconButton(
            icon: Icon(Icons.more_horiz),
            onPressed: () {
              Navigator.pushNamed(context, "/news");
              print("更多");
            },
          ),
        ],
      ),
      drawer: Drawer(
        child: Column(
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Expanded(
                  flex: 1,
                  child: UserAccountsDrawerHeader(
                    accountName: Text("用户名"),
                    accountEmail: Text("邮箱地址@qq.com"),
                    currentAccountPicture: CircleAvatar(
                      backgroundImage: NetworkImage(
                        "https://img1.baidu.com/it/u=2317612037,2363737113&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500",
                      ),
                    ),
                    otherAccountsPictures: [
                      Image.network(
                        "https://img0.baidu.com/it/u=1759892080,1894447401&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500",
                      ),
                      CircleAvatar(
                        backgroundImage: NetworkImage(
                          "https://img0.baidu.com/it/u=1759892080,1894447401&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500",
                        ),
                      ),
                    ],
                    decoration: BoxDecoration(
                      image: DecorationImage(
                        image: NetworkImage(
                          "https://wx2.sinaimg.cn/mw690/006ynJJsly1hthncph0v1j30u00u0agd.jpg",
                        ),
                        fit: BoxFit.cover,
                      ),
                    ),
                  ),
                ),
              ],
            ),

            ListTile(
              leading: CircleAvatar(child: Icon(Icons.people)),
              title: Text("个人中心"),
            ),
            ListTile(
              leading: CircleAvatar(child: Icon(Icons.people)),
              title: Text("系统设置"),
            ),
          ],
        ),
      ),
      body: _pages[_currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: _currentIndex,
        selectedItemColor: Colors.red,
        iconSize: 35,
        type: BottomNavigationBarType.fixed,
        onTap: (index) {
          setState(() {
            _currentIndex = index;
          });
        },
        items: const [
          BottomNavigationBarItem(icon: Icon(Icons.home), label: "Home"),
          BottomNavigationBarItem(
            icon: Icon(Icons.gpp_good),
            label: "GetX",
          ),
          BottomNavigationBarItem(icon: Icon(Icons.message), label: "混合开发"),
          BottomNavigationBarItem(icon: Icon(Icons.developer_mode), label: "动画"),
          BottomNavigationBarItem(icon: Icon(Icons.person), label: "用户"),
        ],
      ),
      floatingActionButton: Container(
        height: 60,
        width: 60,
        padding: EdgeInsets.all(2),
        margin: EdgeInsets.only(top: 30),
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(50),
          boxShadow: [BoxShadow(color: Colors.black26, blurRadius: 5)],
        ),
        child: FloatingActionButton(
          shape: CircleBorder(),
          backgroundColor: _currentIndex == 2 ? Colors.red : Colors.blue,
          child: const Icon(Icons.add),
          onPressed: () {
            setState(() {
              _currentIndex = 2;
            });
          },
        ),
      ),
      floatingActionButtonLocation:
          FloatingActionButtonLocation.centerDocked, //悬浮按钮位置
    );
  }
}
